package com.bwda.dsrs.filecenter.domain.form.fileeditgrantsetting;

import com.bwda.dsrs.filecenter.domain.BusinessConstants;
import io.swagger.annotations.ApiModelProperty;

/**
 * 权限规则
 *
 * @author liangjianyong
 * @date 2019/5/14
 */
public class FileEditGrantBaseForm {

    @ApiModelProperty(value = "只读/编辑权限 0:只读 1：编辑")
    private Integer readonlyEditRight;

    @ApiModelProperty(value = "复制权限  0：禁止  1:允许")
    private Integer copyRight;

    @ApiModelProperty(value = "另存为权限 0：禁止  1:允许")
    private Integer saveAsRight;

    @ApiModelProperty(value = "打印权限  0：禁止  1:允许")
    private Integer printRight;

    /**
     * 默认规则
     */
    public void checkAndReplace(){
        //默认只读
        if(readonlyEditRight==null){
            this.readonlyEditRight= BusinessConstants.OnlineEditRight.NO;
        }
        //只读
        if(this.readonlyEditRight==BusinessConstants.OnlineEditRight.NO){
            this.saveAsRight=BusinessConstants.OnlineEditRight.NO;
            this.printRight=BusinessConstants.OnlineEditRight.NO;
            //默认允许
            if(this.copyRight==null){
                this.copyRight=BusinessConstants.OnlineEditRight.YES;
            }
        }
        //编辑
        if(this.readonlyEditRight==BusinessConstants.OnlineEditRight.YES){
            //默认允许
            this.copyRight=BusinessConstants.OnlineEditRight.YES;
            if(this.saveAsRight==null){
               this.saveAsRight=BusinessConstants.OnlineEditRight.YES;
            }
            if(this.printRight==null){
                this.printRight=BusinessConstants.OnlineEditRight.YES;
            }
        }
    }

}
